<?php

/**
 * Powerdev filter form base class.
 *
 * @package    seth
 * @subpackage filter
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BasePowerdevFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'plant'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => true)),
      'subplant' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Subplant'), 'add_empty' => true)),
      'brand'    => new sfWidgetFormFilterInput(),
      'model'    => new sfWidgetFormFilterInput(),
      'serial'   => new sfWidgetFormFilterInput(),
      'type'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'subtype'  => new sfWidgetFormFilterInput(),
      'power'    => new sfWidgetFormFilterInput(),
      'quantity' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'label'    => new sfWidgetFormFilterInput(),
      'source'   => new sfWidgetFormFilterInput(),
      'address'  => new sfWidgetFormFilterInput(),
      'source2'  => new sfWidgetFormFilterInput(),
      'address2' => new sfWidgetFormFilterInput(),
      'note'     => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'plant'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Plant'), 'column' => 'id')),
      'subplant' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Subplant'), 'column' => 'id')),
      'brand'    => new sfValidatorPass(array('required' => false)),
      'model'    => new sfValidatorPass(array('required' => false)),
      'serial'   => new sfValidatorPass(array('required' => false)),
      'type'     => new sfValidatorPass(array('required' => false)),
      'subtype'  => new sfValidatorPass(array('required' => false)),
      'power'    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'quantity' => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'label'    => new sfValidatorPass(array('required' => false)),
      'source'   => new sfValidatorPass(array('required' => false)),
      'address'  => new sfValidatorPass(array('required' => false)),
      'source2'  => new sfValidatorPass(array('required' => false)),
      'address2' => new sfValidatorPass(array('required' => false)),
      'note'     => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('powerdev_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Powerdev';
  }

  public function getFields()
  {
    return array(
      'id'       => 'Number',
      'plant'    => 'ForeignKey',
      'subplant' => 'ForeignKey',
      'brand'    => 'Text',
      'model'    => 'Text',
      'serial'   => 'Text',
      'type'     => 'Text',
      'subtype'  => 'Text',
      'power'    => 'Number',
      'quantity' => 'Number',
      'label'    => 'Text',
      'source'   => 'Text',
      'address'  => 'Text',
      'source2'  => 'Text',
      'address2' => 'Text',
      'note'     => 'Text',
    );
  }
}
